#include <iostream>
#include <cstring>
using namespace std;

// 定义成员函数比较两只猫的年龄，返回年龄较大的那只猫对象(年龄相同你就返回当前猫对象)

class Cat
{
public:
    Cat(int age, const char *name)
    {
        this->age = age;
        strcpy(this->name, name);
    }

    int getAge()
    {
        return age;
    }

    char *getName()
    {
        return name;
    }
    void showAddress()
    {
        cout << this << endl;
    }

    Cat &maxAge(Cat &other)
    {
        if (this->age > other.getAge())
        {
            return *this;
        }
        else
        {
            return other;
        }
    }

private:
    int age;
    char name[20];
};

int main()
{
    Cat c1(1, "Tom");
    Cat c2(2, "Jerry");

    c1.showAddress();
    c2.showAddress();

    cout << "年龄较大的那只猫是：";
    c1.maxAge(c2).showAddress();
}
